package com.lingjtx.common.pay.client;

import com.alibaba.fastjson2.JSONObject;
import com.lingjtx.common.other.annotation.*;
import com.lingjtx.common.other.http.Call;
import com.lingjtx.common.pay.common.PayUrlPath;
import com.lingjtx.common.pay.model.wx.*;

public interface PayClientApi {

    // 获取微信平台证书
    @Headers({"Accept: application/json"})
    @GET(PayUrlPath.WX_CERTIFICATES)
    Call<Certificates> getCertificates(@Header("Authorization") String authorization);

    // 微信 native 下单
    @Headers({"Accept: application/json", "Content-Type: application/json"})
    @POST(PayUrlPath.WX_NATIVE_ORDER)
    Call<WinXinPrepayResponse> wxPayNative(@Header("Authorization") String authorization, @Body WinXinPrepayRequest request);

    // jsapi 下单
    @Headers({"Accept: application/json", "Content-Type: application/json"})
    @POST(PayUrlPath.WX_JSAPI_ORDER)
    Call<WinXinPrepayResponse> wxPayJsapi(@Header("Authorization") String authorization, @Body WinXinPrepayRequest request);

    // app 下单
    @Headers({"Accept: application/json", "Content-Type: application/json"})
    @POST(PayUrlPath.WX_APP_ORDER)
    Call<WinXinPrepayResponse> wxPayApp(@Header("Authorization") String authorization, @Body WinXinPrepayRequest request);

    // h5 下单
    @Headers({"Accept: application/json", "Content-Type: application/json"})
    @POST(PayUrlPath.WX_H5_ORDER)
    Call<WinXinPrepayResponse> wxPayH5(@Header("Authorization") String authorization, @Body WinXinPrepayRequest request);

    // 商户订单号查询订单
    @Headers({"Accept: application/json"})
    @GET(PayUrlPath.WX_QUERY_ORDER)
    Call<WinXinOrderDetail> wxQueryOrderDetail(@Header("Authorization") String authorization,
                                               @Query("mchid") String mchid,
                                               @Path("out_trade_no") String orderNo);

    // 关闭订单
    @Headers({"Accept: application/json", "Content-Type: application/json"})
    @POST(PayUrlPath.WX_CLOSE_ORDER)
    Call<JSONObject> wxCloseOrder(@Header("Authorization") String authorization,
                                  @Body MchEntity mchid,
                                  @Path("out_trade_no") String orderNo);

    // 退款申请
    @Headers({"Accept: application/json", "Content-Type: application/json"})
    @POST(PayUrlPath.WX_REFUNDS)
    Call<WeixinRefundResponse> wxRefunds(@Header("Authorization") String authorization, @Body WeixinRefundRequest model);

    @POST(PayUrlPath.ALIPAY_GATEWAY)
    Call<String> alipayGateway();
}
